
//导入vue-router路由包
import VueRouter from 'vue-router'
import vue from 'vue'
//导入路由组件
import index from './components/index.vue'
import passage from './components/news/NewsList.vue'
import login from './components/login.vue'
import register from './components/regist.vue'
import NewsInfo from './components/news/NewsInfo.vue'
import GoodsList from './components/goods/goodsList.vue'
import UserInfo from './components/user/userinfo.vue'
import MyMessage from './components/user/MyMessage.vue'
import MyAvatar from './components/user/MyAvatar.vue'
import MyActicle from './components/user/MyActicle.vue'
import MyLike from './components/user/MyLike.vue'
import AdminRegist from './components/adminregist.vue'
import NewsCreate from './components/news/NewsCreate.vue'
import home from './components/home.vue'
import Author from './components/news/author.vue'
import ActivityList from './components/activity/ActivityList.vue'
import poorAreaList from './components/poorarea/poorAreaList'
import poorAreaInfo from './components/poorarea/poorAreaInfo'
import search from './components/search/searchinfo'
import changePassword from './components/user/changePassword'
//定义一个router对象
vue.use(VueRouter)

var router = new VueRouter({
  routes:[
    {
      path:'/',
      redirect:'/index'
    },
    {
      path:'/index',
      component: index
     },
     {path:'/home',component:home},
     {path:'/search',component:search},
    {path:'/passage',component: passage },
    {path:'/login',component:login},
    {path:'/register',component:register},
    {path:'/adminregist',component:AdminRegist},
    {path:'/newsinfo/:id',component:NewsInfo},
    {path:'/author',component:Author},
    {path:'/goodslist',component:GoodsList},
    {path:'/newscreate',component:NewsCreate},
    {path:'/activity',component:ActivityList},
    {path:'/poorarea',component:poorAreaList},
    {path:'/poorareainfo',component:poorAreaInfo},
    //个人中心路由用子路由构架
    {
      path:'/userinfo',
      component:UserInfo,
      redirect:'/mymessage',
      children:[
        {path:'/mymessage',component:MyMessage},
        {path:'/myavatar',component:MyAvatar},
        {path:'/myarticle',component:MyActicle},
        {path:'/mylike',component:MyLike},
        {path:'/changepassword',component:changePassword},
      ]
    },
  ]
})
export default router

// export default new VueRouter ({
//   mode: 'history',
//   base: process.env.BASE_URL,
//   routes: [
//     {
//       path: '/passage',
//       name: 'passage',
//       component: () => import(/* webpackChunkName: "about" */ './components/passage.vue')
//     },
//     {
//       path: '/index',
//       name: 'index',
//       // route level code-splitting
//       // this generates a separate chunk (about.[hash].js) for this route
//       // which is lazy-loaded when the route is visited.
//       component: () => import(/* webpackChunkName: "about" */ './components/index.vue')
//     },
//     {
//       path: '/regist',
//       name: 'regist',
//       component: () => import('./components/regist.vue')
//     },
//   ]
// })
